package com.example.qxfw.backgroundManagement.service.impl;

import com.example.qxfw.backgroundManagement.mapper.WorkforceManagementMapper;
import com.example.qxfw.backgroundManagement.service.WorkforceManagementService;
import com.example.qxfw.rcyw.pojo.JobMake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/************************************
 *
 * @author : HuangDeYin Jolly
 * @since : JDK 11
 * @Date : 2023/7/3  星期一   15:12
 * @description : 此类用来
 ***************************************/
@Service
public class WorkforceManagementServiceImpl implements WorkforceManagementService {

    @Autowired
    private WorkforceManagementMapper workforceManagementMapper;

    @Override
    public List<JobMake> selectJobType() {
        List<JobMake> jobMakes = this.workforceManagementMapper.selectJobType();
        return jobMakes;
    }

    @Override
    public List<JobMake> selectJobNameAndJobType(final String nameType, final String jobName) {


        List<JobMake> jobMakes = this.workforceManagementMapper.selectJobNameAndJobType(nameType, jobName);
        return jobMakes;
    }

    @Override
    public List<JobMake> selectJobName(final String nameType) {
        List<JobMake> jobMakes = this.workforceManagementMapper.selectJobName(nameType);
        return jobMakes;
    }

    @Override
    public Integer insertJobMark(final String jobName,  final String nameType, Date recentMakeTime) {
        Integer insertJobMark = this.workforceManagementMapper.insertJobMark(jobName,  nameType,  recentMakeTime);
        return insertJobMark;
    }

    @Override
    public Integer updateJobMark(JobMake jobMake) {
        Integer updateJobMark = this.workforceManagementMapper.updateJobMark(jobMake.getId(), jobMake.getJobname(), jobMake.getNametype(), jobMake.getMakeshift(), jobMake.getRecentmaketime());
        return updateJobMark;
    }

    @Override
    public Integer deleteJobMark(final int id) {
        Integer deleteJobMark = this.workforceManagementMapper.deleteJobMark(id);
        return deleteJobMark;
    }

    @Override
    public Integer importJobMark(List<JobMake> jobMakelist) {
        this.workforceManagementMapper.clearJobMark();
        int count = 0;
        Integer insertJobMarkId = this.workforceManagementMapper.selcetlastId();
        for (JobMake jobMake : jobMakelist) {
            JobMake jobMake1 = new JobMake();
            if (insertJobMarkId == null) {insertJobMarkId = 0;}
            insertJobMarkId += 1;
            jobMake1.setId(insertJobMarkId);
            jobMake1.setJobname(jobMake.getJobname());
            jobMake1.setNametype(jobMake.getNametype());
            jobMake1.setRecentmaketime(jobMake.getRecentmaketime());
            count += this.workforceManagementMapper.insert(jobMake1);
        }
        return count;
    }

    @Override
    public Integer importJobMark1(List<JobMake> jobMakelist) {
        int count = 0;
        Integer insertJobMarkId = this.workforceManagementMapper.selcetlastId();
        for (JobMake jobMake : jobMakelist) {
            JobMake jobMake1 = new JobMake();
            insertJobMarkId += 1;
            jobMake1.setId(insertJobMarkId);
            jobMake1.setJobname(jobMake.getJobname());
            jobMake1.setNametype(jobMake.getNametype());
            jobMake1.setRecentmaketime(jobMake.getRecentmaketime());
            count += this.workforceManagementMapper.insert(jobMake1);
        }
        return count;
    }

    @Override
    public Integer updateJobMark2(JobMake jobMake) {
        Integer updateJobMark = this.workforceManagementMapper.updateJobMark2(jobMake.getJobname(), jobMake.getNametype(), jobMake.getRecentmaketime());
        return updateJobMark;
    }

    @Override
    public List<JobMake> listJobMark() {
        return this.workforceManagementMapper.listJobMark();
    }
}
